<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@include file="common/header.jsp"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html lang="zh">
<head>
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1"> 
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>注册</title>
</head>
<body>
<div class="htmleaf-container">
	<div class="wrapper">
		<div class="container">
			<h1> 商家注册页面</h1>
			
			<form class="form" action="${pageContext.request.contextPath }/provider/sign.html" 
			method="post" id="submit" enctype="multipart/form-data" onsubmit="return check();">
				<input type="text" placeholder="账号名" id="proName" name="proName" onblur="a1()"><span id="error1"></span><br/>
				<input type="text" placeholder="密码" id="password" name="password"  onblur="a2()"><span id="error2"></span><br/>
				<input type="text" placeholder="确认密码" id="password2" name="password2" onblur="a3()"><span id="error3"></span><br/>
				<input type="text" placeholder="商家电话" id="proPhone" name="proPhone" onblur="a4()"><span id="error4"></span><br/>
				<input type="text" placeholder="商家地址" id="proAddress" name="proAddress" onblur="a5()"><span id="error5"></span><br/>
				<input type="text" placeholder="传真" id="proFax" name="proFax" onblur="a6()"><span id="error6"></span><br/>
				<input type="file" placeholder="营业执照" id="org_PicPath" name="org_PicPath"><span></span><br/>
				<button type="submit" id="login-button" >Login</button><br/>
			</form>
		</div>
		
	</div>
</div>

<script src="${pageContext.request.contextPath }/statics/js/jquery-1.8.3.min.js" type="text/javascript"></script>
<script>
	function a1(){
		var _proName = $("#proName").val();
		var s1 = "";
		$.ajax({
			url : "/Trip/provider/pName",
			data : {proName:_proName},
			dataType : "text",
			type : "get",
			success : function(result){
				$("#error1").html(result);
			if(_proName==""){
			$("#error1").html("用户名不能为空");
			}else if(result==2){
				$("#error1").html("用户名已存在");
			}
			else if(result==1){
				$("#error1").html("用户名可用");
			}
			}
		});
	}
	
	function a2(){
		var pwd = $("#password").val();
		var _pwd2 = $("#password2").val();
		var i= pwd.length;
			if(i==6){
				$("#error2").html("");
			}
			if(pwd==_pwd2){
				$("#error3").html("");
			}
			if(i!=6){
				$("#error2").html("密码长度必须为6位");
			}
			if(pwd!=_pwd2){
				$("#error3").html("两次密码不相同");
			}
	}
	
	function a3(){
		var pwd = $("#password").val();
		var _pwd2 = $("#password2").val();
		var i= pwd.length;
			if(pwd==_pwd2){
				$("#error3").html("");
			}
			if(pwd!=_pwd2){
				$("#error3").html("两次密码不相同");
			}
	}
	
	function a4(){
		var _proPhone = $("#proPhone").val();
		if(_proPhone==""){
			$("#error4").html("未填写")
		}
		if(_proPhone!=""){
			$("#error4").html("")
		}
	}
	
	function a5(){
		var _proPhone = $("#proPhone").val();
		if(_proPhone==""){
			$("#error5").html("未填写")
		}
		if(_proPhone!=""){
			$("#error5").html("")
		}
	}
	
	function a6(){
		var _proPhone = $("#proPhone").val();
		if(_proPhone==""){
			$("#error6").html("未填写")
		}
		if(_proPhone!=""){
			$("#error6").html("")
		}
	}
	
	function check(){
		var _proName = $("#proName").val();
		var name=$("#error1").html();
		var pwd = $("#password").val();
		var _pwd2 = $("#password2").val();
		var len = pwd.length;
		var _proPhone = $("#proPhone").val();
		var _proAddress = $("#proAddress").val();
		var _proFax = $("#proFax").val();
		var _org_PicPath = $("#org_PicPath").val();
		if(_proName == ""|| name =="用户名已存在"||
				pwd == ""|| len !=6 || pwd != _pwd2||
				_pwd2 == ""||
				_proPhone == ""||
				_proAddress == ""||
				_proFax == ""){
			    alert("请完善信息");
			    return false;
			}else if(_org_PicPath==""){
				alert("请上传证件");
				return false;
			}
		}
</script>

<div style="text-align:center;margin:50px 0; font:normal 14px/24px 'MicroSoft YaHei';color:#000000">
</div>
</body>
</html>